Skip to content

feat(completion): mark deprecated symbols with strikethrough#414

Merged
16bit-ykiko merged 1 commit intomainfrom
feat/completion-deprecated
Apr 19, 2026
Merged

feat(completion): mark deprecated symbols with strikethrough#414
16bit-ykiko merged 1 commit intomainfrom
feat/completion-deprecated

Conversation

@16bit-ykiko
Copy link
Copy Markdown
Member

@16bit-ykiko 16bit-ykiko commented Apr 9, 2026

Summary

  • Check CXAvailability_Deprecated on CodeCompletionResult and set CompletionItemTag::Deprecated
  • Editors render deprecated completions with a strikethrough on the label

Test plan

  • DeprecatedTag[[deprecated]] function gets the tag
  • NotDeprecated — normal function has no Deprecated tag
  • All 491 unit tests pass
  • pixi run format clean

Stacked on #411.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Code completion now marks deprecated declarations with a deprecated tag so users can see deprecated items in completion lists.
  • Tests

    • Added unit tests ensuring deprecated declarations produce completion items with the deprecated tag and non-deprecated items do not.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 9, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0bb83b3a-be0e-43d9-a5fb-c0ca530a167b

📥 Commits

Reviewing files that changed from the base of the PR and between 7c50364 and 2c624ad.

📒 Files selected for processing (2)
  • src/feature/code_completion.cpp
  • tests/unit/feature/code_completion_tests.cpp
✅ Files skipped from review due to trivial changes (1)
  • tests/unit/feature/code_completion_tests.cpp
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/feature/code_completion.cpp

📝 Walkthrough

Walkthrough

The code completion collector now propagates deprecation status into completion items. CodeCompletionCollector::try_add accepts an is_deprecated flag and sets CompletionItemTag::Deprecated when true; unit tests were added to verify tagged and untagged cases.

Changes

Cohort / File(s) Summary
Deprecation Tagging Implementation
src/feature/code_completion.cpp
Added is_deprecated parameter to CodeCompletionCollector::try_add and set protocol::CompletionItemTag::Deprecated on created completion items when declarations are deprecated (CXAvailability_Deprecated).
Deprecation Tests
tests/unit/feature/code_completion_tests.cpp
Added two unit tests: one asserting deprecated declarations produce completion items with the Deprecated tag, and one asserting non-deprecated declarations do not include the tag.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Poem

🐰 I nibble bytes and hop in stacks,

I tag old names with gentle tacks,
A deprecated carrot, flagged just so,
So coders know where not to go,
Hooray — completion now says "No!" 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: marking deprecated symbols with strikethrough in code completion.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/completion-deprecated

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Base automatically changed from feat/completion-improvements to main April 9, 2026 08:08
@16bit-ykiko 16bit-ykiko force-pushed the feat/completion-deprecated branch from 558fe87 to 7c50364 Compare April 9, 2026 08:10
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/feature/code_completion.cpp (1)

275-290: ⚠️ Potential issue | 🟠 Major

Propagate deprecation when bundled overloads are merged

On Line 275, tags are set only when a new overload bucket is inserted. In the merge path (Lines 284-290), if a deprecated overload is encountered after a non-deprecated one, the bundled item can incorrectly miss Deprecated.

💡 Proposed fix
                 } else {
                     auto& existing = overloads[it->second];
                     existing.count += 1;
+                    if(is_deprecated) {
+                        if(!existing.item.tags.has_value()) {
+                            existing.item.tags = std::vector<protocol::CompletionItemTag>{};
+                        }
+                        if(std::ranges::find(*existing.item.tags,
+                                             protocol::CompletionItemTag::Deprecated) ==
+                           existing.item.tags->end()) {
+                            existing.item.tags->push_back(protocol::CompletionItemTag::Deprecated);
+                        }
+                    }
                     if(*score > existing.score) {
                         existing.score = *score;
                         existing.item.sort_text = std::format("{}", *score);
                     }
                 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/feature/code_completion.cpp` around lines 275 - 290, When merging into an
existing overload bucket (the branch that updates existing =
overloads[it->second]), ensure deprecation is propagated: if the incoming
overload's is_deprecated (or item.tags contains
protocol::CompletionItemTag::Deprecated) is true then add
protocol::CompletionItemTag::Deprecated to existing.item.tags (or set
existing.item.tags = std::vector{...} if empty) so a later-deprecated overload
won't lose the Deprecated tag; also keep the existing score/count/update logic
(existing.count, existing.score, existing.item.sort_text) unchanged.
🧹 Nitpick comments (1)
tests/unit/feature/code_completion_tests.cpp (1)

195-220: Add a mixed-overload deprecation regression test

These tests cover single-candidate cases well, but they don’t validate bundled overload behavior when only one overload is deprecated. Add one case to ensure the bundled item still carries Deprecated.

🧪 Suggested test addition
+TEST_CASE(DeprecatedTagBundledOverloads) {
+    code_complete(R"cpp(
+int foooo(int x);
+[[deprecated]] int foooo(int x, int y);
+int z = fo$(pos)
+)cpp");
+
+    auto it = find_item("foooo");
+    ASSERT_TRUE(it != items.end());
+    ASSERT_TRUE(it->tags.has_value());
+    ASSERT_TRUE(std::ranges::find(*it->tags, protocol::CompletionItemTag::Deprecated) !=
+                it->tags->end());
+}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/unit/feature/code_completion_tests.cpp` around lines 195 - 220, Add a
new TEST_CASE (e.g., MixedOverloadDeprecated) in the same file that calls
code_complete with two overloaded declarations where one overload is marked
[[deprecated]] and the other is not, then locate the completion item via
find_item (same "foooo" name used in existing tests) and assert that the
returned completion's tags (it->tags) include
protocol::CompletionItemTag::Deprecated; use the existing pattern of checking
items, it != items.end(), and checking it->tags.has_value() and that
std::ranges::find(*it->tags, protocol::CompletionItemTag::Deprecated) !=
it->tags->end() so the bundled overload item is marked Deprecated when at least
one overload is deprecated.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@src/feature/code_completion.cpp`:
- Around line 275-290: When merging into an existing overload bucket (the branch
that updates existing = overloads[it->second]), ensure deprecation is
propagated: if the incoming overload's is_deprecated (or item.tags contains
protocol::CompletionItemTag::Deprecated) is true then add
protocol::CompletionItemTag::Deprecated to existing.item.tags (or set
existing.item.tags = std::vector{...} if empty) so a later-deprecated overload
won't lose the Deprecated tag; also keep the existing score/count/update logic
(existing.count, existing.score, existing.item.sort_text) unchanged.

---

Nitpick comments:
In `@tests/unit/feature/code_completion_tests.cpp`:
- Around line 195-220: Add a new TEST_CASE (e.g., MixedOverloadDeprecated) in
the same file that calls code_complete with two overloaded declarations where
one overload is marked [[deprecated]] and the other is not, then locate the
completion item via find_item (same "foooo" name used in existing tests) and
assert that the returned completion's tags (it->tags) include
protocol::CompletionItemTag::Deprecated; use the existing pattern of checking
items, it != items.end(), and checking it->tags.has_value() and that
std::ranges::find(*it->tags, protocol::CompletionItemTag::Deprecated) !=
it->tags->end() so the bundled overload item is marked Deprecated when at least
one overload is deprecated.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1bb99321-f820-4bbe-b3c9-3a2de986874b

📥 Commits

Reviewing files that changed from the base of the PR and between bd238fe and 7c50364.

📒 Files selected for processing (2)
  • src/feature/code_completion.cpp
  • tests/unit/feature/code_completion_tests.cpp

Check CXAvailability_Deprecated on CodeCompletionResult and set
CompletionItemTag::Deprecated on the CompletionItem. Editors render
this as a strikethrough on the completion label.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@16bit-ykiko 16bit-ykiko force-pushed the feat/completion-deprecated branch from 7c50364 to 2c624ad Compare April 18, 2026 07:01
@16bit-ykiko 16bit-ykiko merged commit 3fa653b into main Apr 19, 2026
15 checks passed
@16bit-ykiko 16bit-ykiko deleted the feat/completion-deprecated branch April 19, 2026 05:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant